<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>25_定时器-取消循环定时器</title>
    </head>
    <body>
        <button>取消循环定时器</button>

        <script>
            var timer = setInterval(function(){
                console.log('想去贵州吃酸辣的火锅');
            },2000);


            var btn = document.querySelector('button');
            btn.onclick = function(){
                clearInterval(timer);
            }
        </script>
    </body>
</html>